<?php

namespace app\common\library;
use Client;
use KyTraceQueryReq;
/**
 * 百世快递开放接口
 * @classname Yunda
 * @package app\common\library
 */
class Baishi
{
    public string $url     = 'http://edi-v5.800best.com/gateway/v5api/kyapi';
    public string $partnerID     = '69212';
    public string $partnerKey = 'e1vxnqckwr57';
    /**
     * 发送请求
     ** @param $shipId
     * @return mixed
     *
     */
    public function send($shipId){
        $format = "JSON";//如果是JSON的数据格式，填JSON
        include_once  ROOT_PATH."kyapi/Client.php";
        include_once  ROOT_PATH."kyapi/kyTraceQuery/request/KyTraceQueryReq.php";
        $client = new Client($this->url, $this->partnerID, $this->partnerKey, $format);
        $kyTraceQueryReq = new KyTraceQueryReq();
        $kyTraceQueryReq->setLogisticCompanyID("BESTQJT");
        $kyTraceQueryReq->setLogisticID($shipId);
        $codes = Array($shipId);
        $kyTraceQueryReq->setCodes($codes);
        $kyTraceQueryRsp = $client->executed($kyTraceQueryReq);
        return json_decode( $kyTraceQueryRsp,true);
    }
}
